{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "QUANTAXIS>> start QUANTAXIS\n",
      "QUANTAXIS>> Welcome to QUANTAXIS, the Version is 1.1.4\n",
      "QUANTAXIS>>  \n",
      " ```````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` \n",
      "  ``########`````##````````##``````````##`````````####````````##```##########````````#``````##``````###```##`````######`` \n",
      "  `##``````## ```##````````##`````````####````````##`##```````##```````##```````````###``````##````##`````##```##`````##` \n",
      "  ##````````##```##````````##````````##`##````````##``##``````##```````##``````````####```````#```##``````##```##``````## \n",
      "  ##````````##```##````````##```````##```##```````##```##`````##```````##`````````##`##```````##`##```````##````##``````` \n",
      "  ##````````##```##````````##``````##`````##``````##````##````##```````##````````##``###```````###````````##`````##`````` \n",
      "  ##````````##```##````````##``````##``````##`````##`````##```##```````##```````##````##```````###````````##``````###```` \n",
      "  ##````````##```##````````##`````##````````##````##``````##``##```````##``````##``````##`````##`##```````##````````##``` \n",
      "  ##````````##```##````````##````#############````##```````##`##```````##`````###########`````##``##``````##`````````##`` \n",
      "  ###```````##```##````````##```##```````````##```##```````##`##```````##````##`````````##```##```##``````##```##`````##` \n",
      "  `##``````###````##``````###``##`````````````##``##````````####```````##```##``````````##``###````##`````##````##`````## \n",
      "  ``#########``````########```##``````````````###`##``````````##```````##``##````````````##`##``````##````##`````###``### \n",
      "  ````````#####`````````````````````````````````````````````````````````````````````````````````````````````````````##``  \n",
      "  ``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` \n",
      "  ``````````````````````````Copyright``yutiansut``2018``````QUANTITATIVE FINANCIAL FRAMEWORK````````````````````````````` \n",
      "  ``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` \n",
      " ```````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` \n",
      " ```````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` \n",
      " \n"
     ]
    }
   ],
   "source": [
    "import QUANTAXIS as QA"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 在这里我们演示一下 下单/交易/结算的整个流程"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们首先会建立一个账户类和一个回测类\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    " # 初始化一个account\n",
    "Account=QA.QA_Account()\n",
    "\n",
    "# 初始化一个回测类\n",
    "B = QA.QA_BacktestBroker()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "在第一天的时候,全仓买入 000001"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 全仓买入'000001'\n",
    "\n",
    "Order=Account.send_order(code='000001',\n",
    "                        price=11,\n",
    "                        money=0.04*Account.cash_available,\n",
    "                        time='2018-05-09',\n",
    "                        towards=QA.ORDER_DIRECTION.BUY,\n",
    "                        order_model=QA.ORDER_MODEL.MARKET,\n",
    "                        amount_model=QA.AMOUNT_MODEL.BY_MONEY\n",
    "                        )\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ORDER的占用资金: 39609.9\n"
     ]
    }
   ],
   "source": [
    "\n",
    "## 打印order的占用资金\n",
    "print('ORDER的占用资金: {}'.format((Order.amount*Order.price)*(1+Account.commission_coeff)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "账户剩余资金 :960000.0\n"
     ]
    }
   ],
   "source": [
    "# 账户剩余资金\n",
    "print('账户剩余资金 :{}'.format(Account.cash_available))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Series([], Name: amount, dtype: float64)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.hold"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Series([], Name: amount, dtype: float64)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.init_hold"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Series([], Name: amount, dtype: float64)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.hold_available"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "此时的账户cash并未减少,因为此过程为申报订单(已委托 未成交状态)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "回测类接受订单 并返回订单(如果创建成功)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "< QA_Order realorder_id Order_dL4nhik6 datetime:2018-05-09 09:30:00 code:000001 amount:3600 price:10.955 towards:1 btype:stock_cn order_id:Order_dL4nhik6 account:Acc_uME9Gtp4 status:queued >\n"
     ]
    }
   ],
   "source": [
    "rec_mes=B.receive_order(QA.QA_Event(order=Order))\n",
    "print(rec_mes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "#B.query_orders(rec_mes.account_cookie,rec_mes.realorder_id)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>order_time</th>\n",
       "      <th>code</th>\n",
       "      <th>name</th>\n",
       "      <th>towards</th>\n",
       "      <th>trade_price</th>\n",
       "      <th>order_price</th>\n",
       "      <th>status</th>\n",
       "      <th>order_amount</th>\n",
       "      <th>trade_amount</th>\n",
       "      <th>cancel_amount</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>account_cookie</th>\n",
       "      <th>realorder_id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Acc_uME9Gtp4</th>\n",
       "      <th>Order_dL4nhik6</th>\n",
       "      <td>2018-05-09 09:31:00</td>\n",
       "      <td>000001</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "      <td>10.96</td>\n",
       "      <td>10.955</td>\n",
       "      <td>trade_success</td>\n",
       "      <td>3600</td>\n",
       "      <td>3600</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                        order_time    code  name  towards  \\\n",
       "account_cookie realorder_id                                                 \n",
       "Acc_uME9Gtp4   Order_dL4nhik6  2018-05-09 09:31:00  000001  None        1   \n",
       "\n",
       "                               trade_price  order_price         status  \\\n",
       "account_cookie realorder_id                                              \n",
       "Acc_uME9Gtp4   Order_dL4nhik6        10.96       10.955  trade_success   \n",
       "\n",
       "                               order_amount  trade_amount  cancel_amount  \n",
       "account_cookie realorder_id                                               \n",
       "Acc_uME9Gtp4   Order_dL4nhik6          3600          3600              0  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "B.query_orders(Account.account_cookie)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "#pd.DataFrame(list(B.deal_message.values()),columns=B.orderstatus_headers).set_index(['account_cookie','realorder_id'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>trade_time</th>\n",
       "      <th>code</th>\n",
       "      <th>name</th>\n",
       "      <th>towards</th>\n",
       "      <th>trade_amount</th>\n",
       "      <th>trade_price</th>\n",
       "      <th>trade_money</th>\n",
       "      <th>trade_id</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>account_cookie</th>\n",
       "      <th>realorder_id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Acc_uME9Gtp4</th>\n",
       "      <th>Order_dL4nhik6</th>\n",
       "      <td>2018-05-09 00:00:00</td>\n",
       "      <td>000001</td>\n",
       "      <td>None</td>\n",
       "      <td>1</td>\n",
       "      <td>3600</td>\n",
       "      <td>10.96</td>\n",
       "      <td>39447.8595</td>\n",
       "      <td>Trade_4qeE9kXv</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                        trade_time    code  name  towards  \\\n",
       "account_cookie realorder_id                                                 \n",
       "Acc_uME9Gtp4   Order_dL4nhik6  2018-05-09 00:00:00  000001  None        1   \n",
       "\n",
       "                               trade_amount  trade_price  trade_money  \\\n",
       "account_cookie realorder_id                                             \n",
       "Acc_uME9Gtp4   Order_dL4nhik6          3600        10.96   39447.8595   \n",
       "\n",
       "                                     trade_id  \n",
       "account_cookie realorder_id                    \n",
       "Acc_uME9Gtp4   Order_dL4nhik6  Trade_4qeE9kXv  "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "B.query_orders(Account.account_cookie,'filled')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "receive deal\n"
     ]
    }
   ],
   "source": [
    "trade_mes=B.query_orders(Account.account_cookie,'filled')\n",
    "res=trade_mes.loc[Order.account_cookie,Order.realorder_id]\n",
    "Order.trade(res.trade_id,res.trade_price,res.trade_amount,res.trade_time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Order.trade((trade_id, trade_price, trade_amount, trade_time))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "账户类接收到回测返回的回报信息,更新账户"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>datetime</th>\n",
       "      <th>code</th>\n",
       "      <th>price</th>\n",
       "      <th>amount</th>\n",
       "      <th>cash</th>\n",
       "      <th>order_id</th>\n",
       "      <th>realorder_id</th>\n",
       "      <th>trade_id</th>\n",
       "      <th>account_cookie</th>\n",
       "      <th>commission</th>\n",
       "      <th>tax</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018-05-09 00:00:00</td>\n",
       "      <td>000001</td>\n",
       "      <td>10.96</td>\n",
       "      <td>3600</td>\n",
       "      <td>960534.136</td>\n",
       "      <td>Order_dL4nhik6</td>\n",
       "      <td>Order_dL4nhik6</td>\n",
       "      <td>Trade_4qeE9kXv</td>\n",
       "      <td>Acc_uME9Gtp4</td>\n",
       "      <td>9.864</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              datetime    code  price  amount        cash        order_id  \\\n",
       "0  2018-05-09 00:00:00  000001  10.96    3600  960534.136  Order_dL4nhik6   \n",
       "\n",
       "     realorder_id        trade_id account_cookie  commission  tax  \n",
       "0  Order_dL4nhik6  Trade_4qeE9kXv   Acc_uME9Gtp4       9.864    0  "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.history_table"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "此时我们可以打印一下现在的状态(现在的状态可以理解为在交易时 买入一只000001股票,但当天尚未收盘)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "账户的可用资金 960534.1359999999\n"
     ]
    }
   ],
   "source": [
    "print('账户的可用资金 {}'.format(Account.cash_available))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "code\n",
       "000001    3600\n",
       "Name: amount, dtype: int64"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.hold"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "code\n",
       "000001    3600\n",
       "Name: amount, dtype: int64"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.hold_available"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "Account.init_hold.index_name='code'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "code\n",
       "000001    3600\n",
       "Name: amount, dtype: int64"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.concat([Account.hold_available,Account.init_hold])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "code\n",
       "000001    3600\n",
       "Name: amount, dtype: int64"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "+Account.hold_available"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们注意到 当最初申报订单的时候,可用资金只有950.2999999999302元,而买入成功后,可用资金有3339.9289999998837元,原因是下单的时候模式是市价单模式(QA.ORDER_MODEL.MARKET),故实际成交金额为10.96元"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "买入以后 账户的持仓为90800股 000001"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "code\n",
       "000001    3600\n",
       "Name: amount, dtype: int64"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.hold"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "买入后账户现金表被扩展"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1000000, 960534.1359999999]"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.cash"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "因为是t+1的A股市场,故此时可卖数量为0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Series([], Name: amount, dtype: float64)"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.sell_available"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 执行结算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "Account.settle()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 结算后"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1000000, 960534.1359999999]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.cash"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "960534.1359999999"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.cash_available"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "code\n",
       "000001    3600\n",
       "Name: amount, dtype: int64"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.sell_available"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "code\n",
       "000001    3600\n",
       "Name: amount, dtype: int64"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.hold"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 执行卖出操作"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "现在的持仓为: 000001 90800股"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [],
   "source": [
    "holdnum=Account.sell_available.get('000001',0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3600"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "holdnum"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "申报一个卖出单,把可卖全部卖出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [],
   "source": [
    "Order=Account.send_order(code='000001',\n",
    "                        price=11,\n",
    "                        amount=holdnum,\n",
    "                        time='2018-05-10',\n",
    "                        towards=QA.ORDER_DIRECTION.SELL,\n",
    "                        order_model=QA.ORDER_MODEL.MARKET,\n",
    "                        amount_model=QA.AMOUNT_MODEL.BY_AMOUNT\n",
    "                        )\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "< QA_Order realorder_id Order_xaQklGso datetime:2018-05-10 09:31:00 code:000001 amount:3600 price:11 towards:-1 btype:stock_cn order_id:Order_xaQklGso account:Acc_uME9Gtp4 status:queued >"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Order"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "960534.1359999999"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.cash_available  # 因为此时订单尚未申报成功 可用现金不变"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "< QA_Order realorder_id Order_xaQklGso datetime:2018-05-10 09:30:00 code:000001 amount:3600 price:11.0 towards:-1 btype:stock_cn order_id:Order_xaQklGso account:Acc_uME9Gtp4 status:queued >\n"
     ]
    }
   ],
   "source": [
    "rec_mes=B.receive_order(QA.QA_Event(order=Order))\n",
    "print(rec_mes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "receive deal\n"
     ]
    }
   ],
   "source": [
    "trade_mes=B.query_orders(Account.account_cookie,'filled')\n",
    "res=trade_mes.loc[Order.account_cookie,Order.realorder_id]\n",
    "Order.trade(res.trade_id,res.trade_price,res.trade_amount,res.trade_time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1000084.6359999999"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.cash_available # 此时订单已成交 cash_available立刻结转"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>datetime</th>\n",
       "      <th>code</th>\n",
       "      <th>price</th>\n",
       "      <th>amount</th>\n",
       "      <th>cash</th>\n",
       "      <th>order_id</th>\n",
       "      <th>realorder_id</th>\n",
       "      <th>trade_id</th>\n",
       "      <th>account_cookie</th>\n",
       "      <th>commission</th>\n",
       "      <th>tax</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018-05-09 00:00:00</td>\n",
       "      <td>000001</td>\n",
       "      <td>10.96</td>\n",
       "      <td>3600</td>\n",
       "      <td>960534.136</td>\n",
       "      <td>Order_dL4nhik6</td>\n",
       "      <td>Order_dL4nhik6</td>\n",
       "      <td>Trade_4qeE9kXv</td>\n",
       "      <td>Acc_uME9Gtp4</td>\n",
       "      <td>9.864</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2018-05-10 00:00:00</td>\n",
       "      <td>000001</td>\n",
       "      <td>11.00</td>\n",
       "      <td>-3600</td>\n",
       "      <td>1000084.636</td>\n",
       "      <td>Order_xaQklGso</td>\n",
       "      <td>Order_xaQklGso</td>\n",
       "      <td>Trade_1ckWO95u</td>\n",
       "      <td>Acc_uME9Gtp4</td>\n",
       "      <td>9.900</td>\n",
       "      <td>39.6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              datetime    code  price  amount         cash        order_id  \\\n",
       "0  2018-05-09 00:00:00  000001  10.96    3600   960534.136  Order_dL4nhik6   \n",
       "1  2018-05-10 00:00:00  000001  11.00   -3600  1000084.636  Order_xaQklGso   \n",
       "\n",
       "     realorder_id        trade_id account_cookie  commission   tax  \n",
       "0  Order_dL4nhik6  Trade_4qeE9kXv   Acc_uME9Gtp4       9.864   0.0  \n",
       "1  Order_xaQklGso  Trade_1ckWO95u   Acc_uME9Gtp4       9.900  39.6  "
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.history_table"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<QA_ORDERQueue>"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.orders"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Order_dL4nhik6': < QA_Order realorder_id Order_dL4nhik6 datetime:2018-05-09 09:30:00 code:000001 amount:3600 price:10.955 towards:1 btype:stock_cn order_id:Order_dL4nhik6 account:Acc_uME9Gtp4 status:success_all >,\n",
       " 'Order_xaQklGso': < QA_Order realorder_id Order_xaQklGso datetime:2018-05-10 09:30:00 code:000001 amount:3600 price:11.0 towards:-1 btype:stock_cn order_id:Order_xaQklGso account:Acc_uME9Gtp4 status:success_all >}"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Account.orders.order_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 测试T0账户"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [],
   "source": [
    " # 初始化一个account\n",
    "AccountT0=QA.QA_Account(running_environment=QA.RUNNING_ENVIRONMENT.TZERO,init_hold={'000001':10000},init_cash=200000)\n",
    "\n",
    "# 初始化一个回测类\n",
    "B = QA.QA_BacktestBroker()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'cash': 200000, 'hold': {'000001': 10000}}"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.init_assets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "code\n",
       "000001    10000\n",
       "Name: amount, dtype: int64"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.init_hold"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Series([], Name: amount, dtype: float64)"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.hold_available"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "code\n",
       "000001    10000\n",
       "Name: amount, dtype: int64"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.sell_available"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [],
   "source": [
    "Order=AccountT0.send_order(code='000001',\n",
    "                        price=11,\n",
    "                        amount=AccountT0.sell_available.get('000001',0),\n",
    "                        time='2018-05-10',\n",
    "                        towards=QA.ORDER_DIRECTION.SELL,\n",
    "                        order_model=QA.ORDER_MODEL.MARKET,\n",
    "                        amount_model=QA.AMOUNT_MODEL.BY_AMOUNT\n",
    "                        )\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2018-05-10 09:31:00'"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Order.datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "< QA_Order realorder_id Order_aFpZ98Yk datetime:2018-05-10 09:30:00 code:000001 amount:10000 price:11.0 towards:-1 btype:stock_cn order_id:Order_aFpZ98Yk account:Acc_WTAuvjiX status:queued >\n"
     ]
    }
   ],
   "source": [
    "rec_mes=B.receive_order(QA.QA_Event(order=Order))\n",
    "print(rec_mes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "< QA_Order realorder_id Order_aFpZ98Yk datetime:2018-05-10 09:30:00 code:000001 amount:10000 price:11.0 towards:-1 btype:stock_cn order_id:Order_aFpZ98Yk account:Acc_WTAuvjiX status:queued >"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rec_mes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>trade_time</th>\n",
       "      <th>code</th>\n",
       "      <th>name</th>\n",
       "      <th>towards</th>\n",
       "      <th>trade_amount</th>\n",
       "      <th>trade_price</th>\n",
       "      <th>trade_money</th>\n",
       "      <th>trade_id</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>account_cookie</th>\n",
       "      <th>realorder_id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Acc_WTAuvjiX</th>\n",
       "      <th>Order_aFpZ98Yk</th>\n",
       "      <td>2018-05-10 00:00:00</td>\n",
       "      <td>000001</td>\n",
       "      <td>None</td>\n",
       "      <td>-1</td>\n",
       "      <td>10000</td>\n",
       "      <td>11.0</td>\n",
       "      <td>110137.5</td>\n",
       "      <td>Trade_soEa4gQc</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                        trade_time    code  name  towards  \\\n",
       "account_cookie realorder_id                                                 \n",
       "Acc_WTAuvjiX   Order_aFpZ98Yk  2018-05-10 00:00:00  000001  None       -1   \n",
       "\n",
       "                               trade_amount  trade_price  trade_money  \\\n",
       "account_cookie realorder_id                                             \n",
       "Acc_WTAuvjiX   Order_aFpZ98Yk         10000         11.0     110137.5   \n",
       "\n",
       "                                     trade_id  \n",
       "account_cookie realorder_id                    \n",
       "Acc_WTAuvjiX   Order_aFpZ98Yk  Trade_soEa4gQc  "
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "B.query_orders(AccountT0.account_cookie,'filled')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "receive deal\n"
     ]
    }
   ],
   "source": [
    "trade_mes=B.query_orders(AccountT0.account_cookie,'filled')\n",
    "res=trade_mes.loc[Order.account_cookie,Order.realorder_id]\n",
    "Order.trade(res.trade_id,res.trade_price,res.trade_amount,res.trade_time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "code\n",
       "000001    0\n",
       "Name: amount, dtype: int64"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.sell_available"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['2018-05-10 00:00:00']"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Order.trade_time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "code\n",
       "000001    10000\n",
       "Name: amount, dtype: int64"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.buy_available"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "code\n",
       "000001   -10000\n",
       "Name: amount, dtype: int64"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.hold_available"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2018, 9, 5, 11, 41, 53, 764872)"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.running_time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2018-05-10 00:00:00'"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10000"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.buy_available.get('000001')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [],
   "source": [
    "r=AccountT0.close_positions_order"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2018-05-10'"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.date"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'price': 0, 'datetime': '2018-05-10 15:00:00', 'date': '2018-05-10', 'sending_time': '2018-05-10 15:00:00', 'trade_time': [], 'amount': 10000, 'trade_amount': 0, 'cancel_amount': 0, 'towards': 1, 'code': '000001', 'user': None, 'market_type': 'stock_cn', 'frequence': 'day', 'account_cookie': 'Acc_WTAuvjiX', 'strategy': None, 'type': 'stock_cn', 'order_model': 'CLOSE', 'amount_model': 'by_amount', 'order_id': 'Order_rgq2nGku', 'realorder_id': 'Order_rgq2nGku', 'commission_coeff': 0.00025, 'tax_coeff': 0.001, 'trade_id': [], 'trade_price': 0, 'callback': <bound method QA_Account.receive_deal of < QA_Account Acc_WTAuvjiX>>, 'money': 0.0, 'reason': None, '_status': 'new'}\n",
      "receive deal\n"
     ]
    }
   ],
   "source": [
    "for Order in r:\n",
    "    print(vars(Order))\n",
    "    rec_mes=B.receive_order(QA.QA_Event(order=Order))\n",
    "    trade_mes=B.query_orders(AccountT0.account_cookie,'filled')\n",
    "    res=trade_mes.loc[Order.account_cookie,Order.realorder_id]\n",
    "    Order.trade(res.trade_id,res.trade_price,res.trade_amount,res.trade_time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[200000, 309862.5, 199734.975]"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.cash"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "code\n",
       "000001    0\n",
       "Name: amount, dtype: int64"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.sell_available"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Series([], Name: amount, dtype: float64)"
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.hold_available"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "code\n",
       "000001    10000\n",
       "Name: amount, dtype: int64"
      ]
     },
     "execution_count": 97,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.hold"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {},
   "outputs": [],
   "source": [
    "AccountT0.settle()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>code</th>\n",
       "      <th>000001</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th>account_cookie</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-05-10</th>\n",
       "      <th>Acc_WTAuvjiX</th>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "code                       000001\n",
       "date       account_cookie        \n",
       "2018-05-10 Acc_WTAuvjiX         0"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.daily_hold"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>cash</th>\n",
       "      <th>datetime</th>\n",
       "      <th>date</th>\n",
       "      <th>account_cookie</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th>account_cookie</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-05-10</th>\n",
       "      <th>Acc_WTAuvjiX</th>\n",
       "      <td>199735</td>\n",
       "      <td>2018-05-10 00:00:00</td>\n",
       "      <td>2018-05-10</td>\n",
       "      <td>Acc_WTAuvjiX</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             cash             datetime       date  \\\n",
       "date       account_cookie                                           \n",
       "2018-05-10 Acc_WTAuvjiX    199735  2018-05-10 00:00:00 2018-05-10   \n",
       "\n",
       "                          account_cookie  \n",
       "date       account_cookie                 \n",
       "2018-05-10 Acc_WTAuvjiX     Acc_WTAuvjiX  "
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.daily_cash"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "code\n",
       "000001    10000\n",
       "Name: amount, dtype: int64"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.hold_table()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Series([], dtype: float64)"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.hold_price()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2018-05-11 09:30:00'"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "code\n",
       "000001    10000\n",
       "Name: amount, dtype: int64"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "AccountT0.sell_available"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [],
   "source": [
    "risk_t0=QA.QA_Risk(AccountT0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'cash': 200000, 'hold': {'000001': 10000}}"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "risk_t0.init_assets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "date\n",
       "2018-05-10    265.025\n",
       "Name: 0, dtype: float64"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "risk_t0.init_cash-risk_t0.assets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.001325124999999927"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "risk_t0.assets.iloc[-1]/risk_t0.init_cash-1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'total_buyandsell': -99.99,\n",
       " 'total_tax': -110.0,\n",
       " 'total_commission': -55.03,\n",
       " 'total_profit': -265.02}"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "risk_t0.profit_construct"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 测试期货账户"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "QUANTAXIS>> Selecting the Best Server IP of TDX\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "USING DEFAULT STOCK IP\n",
      "USING DEFAULT FUTURE IP\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "QUANTAXIS>> === The BEST SERVER ===\n",
      " stock_ip 60.191.117.167 future_ip 120.24.0.77\n"
     ]
    }
   ],
   "source": [
    "rb=QA.QA_fetch_get_future_min('tdx','RBL8','2018-01-01','2018-02-28',frequence='15min')\n",
    "rb_ds=QA.QA_DataStruct_Future_min(rb.set_index(['datetime','code']))\n",
    "\n",
    "AccountFuture=QA.QA_Account(init_cash=1000000,allow_sellopen=True,allow_t0=True,account_cookie='future_test',market_type=QA.MARKET_TYPE.FUTURE_CN,frequence=QA.FREQUENCE.FIFTEEN_MIN)\n",
    "\n",
    "\n",
    "#Account.reset_assets(10000000)\n",
    "Broker=QA.QA_BacktestBroker()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>close</th>\n",
       "      <th>position</th>\n",
       "      <th>trade</th>\n",
       "      <th>price</th>\n",
       "      <th>datetime</th>\n",
       "      <th>amount</th>\n",
       "      <th>code</th>\n",
       "      <th>date</th>\n",
       "      <th>date_stamp</th>\n",
       "      <th>time_stamp</th>\n",
       "      <th>type</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>datetime</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-01-02 09:15:00</th>\n",
       "      <td>3801.0</td>\n",
       "      <td>3809.0</td>\n",
       "      <td>3794.0</td>\n",
       "      <td>3798.0</td>\n",
       "      <td>2520510</td>\n",
       "      <td>312684</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-02 09:15:00</td>\n",
       "      <td>3.531987e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-02</td>\n",
       "      <td>1.514822e+09</td>\n",
       "      <td>1.514856e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-02 09:30:00</th>\n",
       "      <td>3799.0</td>\n",
       "      <td>3834.0</td>\n",
       "      <td>3797.0</td>\n",
       "      <td>3830.0</td>\n",
       "      <td>2501350</td>\n",
       "      <td>418536</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-02 09:30:00</td>\n",
       "      <td>3.505138e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-02</td>\n",
       "      <td>1.514822e+09</td>\n",
       "      <td>1.514857e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-02 09:45:00</th>\n",
       "      <td>3829.0</td>\n",
       "      <td>3831.0</td>\n",
       "      <td>3819.0</td>\n",
       "      <td>3822.0</td>\n",
       "      <td>2498648</td>\n",
       "      <td>137928</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-02 09:45:00</td>\n",
       "      <td>3.501352e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-02</td>\n",
       "      <td>1.514822e+09</td>\n",
       "      <td>1.514858e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-02 10:00:00</th>\n",
       "      <td>3823.0</td>\n",
       "      <td>3824.0</td>\n",
       "      <td>3812.0</td>\n",
       "      <td>3822.0</td>\n",
       "      <td>2501706</td>\n",
       "      <td>116806</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-02 10:00:00</td>\n",
       "      <td>3.505637e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-02</td>\n",
       "      <td>1.514822e+09</td>\n",
       "      <td>1.514858e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-02 10:15:00</th>\n",
       "      <td>3822.0</td>\n",
       "      <td>3825.0</td>\n",
       "      <td>3818.0</td>\n",
       "      <td>3824.0</td>\n",
       "      <td>2510106</td>\n",
       "      <td>68888</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-02 10:15:00</td>\n",
       "      <td>3.517408e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-02</td>\n",
       "      <td>1.514822e+09</td>\n",
       "      <td>1.514859e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-02 10:45:00</th>\n",
       "      <td>3824.0</td>\n",
       "      <td>3828.0</td>\n",
       "      <td>3821.0</td>\n",
       "      <td>3823.0</td>\n",
       "      <td>2513434</td>\n",
       "      <td>71846</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-02 10:45:00</td>\n",
       "      <td>3.522071e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-02</td>\n",
       "      <td>1.514822e+09</td>\n",
       "      <td>1.514861e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-02 11:00:00</th>\n",
       "      <td>3824.0</td>\n",
       "      <td>3833.0</td>\n",
       "      <td>3820.0</td>\n",
       "      <td>3824.0</td>\n",
       "      <td>2526064</td>\n",
       "      <td>156954</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-02 11:00:00</td>\n",
       "      <td>3.539770e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-02</td>\n",
       "      <td>1.514822e+09</td>\n",
       "      <td>1.514862e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-02 11:15:00</th>\n",
       "      <td>3824.0</td>\n",
       "      <td>3830.0</td>\n",
       "      <td>3821.0</td>\n",
       "      <td>3826.0</td>\n",
       "      <td>2521712</td>\n",
       "      <td>77962</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-02 11:15:00</td>\n",
       "      <td>3.533671e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-02</td>\n",
       "      <td>1.514822e+09</td>\n",
       "      <td>1.514863e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-02 11:30:00</th>\n",
       "      <td>3825.0</td>\n",
       "      <td>3872.0</td>\n",
       "      <td>3819.0</td>\n",
       "      <td>3871.0</td>\n",
       "      <td>2464210</td>\n",
       "      <td>538316</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-02 11:30:00</td>\n",
       "      <td>3.453094e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-02</td>\n",
       "      <td>1.514822e+09</td>\n",
       "      <td>1.514864e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-02 13:45:00</th>\n",
       "      <td>3872.0</td>\n",
       "      <td>3879.0</td>\n",
       "      <td>3867.0</td>\n",
       "      <td>3871.0</td>\n",
       "      <td>2437082</td>\n",
       "      <td>339672</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-02 13:45:00</td>\n",
       "      <td>3.415079e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-02</td>\n",
       "      <td>1.514822e+09</td>\n",
       "      <td>1.514872e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-02 14:00:00</th>\n",
       "      <td>3873.0</td>\n",
       "      <td>3874.0</td>\n",
       "      <td>3862.0</td>\n",
       "      <td>3866.0</td>\n",
       "      <td>2441464</td>\n",
       "      <td>122992</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-02 14:00:00</td>\n",
       "      <td>3.421220e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-02</td>\n",
       "      <td>1.514822e+09</td>\n",
       "      <td>1.514873e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-02 14:15:00</th>\n",
       "      <td>3866.0</td>\n",
       "      <td>3875.0</td>\n",
       "      <td>3864.0</td>\n",
       "      <td>3875.0</td>\n",
       "      <td>2448522</td>\n",
       "      <td>93220</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-02 14:15:00</td>\n",
       "      <td>3.431110e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-02</td>\n",
       "      <td>1.514822e+09</td>\n",
       "      <td>1.514874e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-02 14:30:00</th>\n",
       "      <td>3874.0</td>\n",
       "      <td>3877.0</td>\n",
       "      <td>3867.0</td>\n",
       "      <td>3873.0</td>\n",
       "      <td>2455406</td>\n",
       "      <td>89550</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-02 14:30:00</td>\n",
       "      <td>3.440757e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-02</td>\n",
       "      <td>1.514822e+09</td>\n",
       "      <td>1.514875e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-02 14:45:00</th>\n",
       "      <td>3873.0</td>\n",
       "      <td>3886.0</td>\n",
       "      <td>3872.0</td>\n",
       "      <td>3879.0</td>\n",
       "      <td>2449654</td>\n",
       "      <td>209192</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-02 14:45:00</td>\n",
       "      <td>3.432696e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-02</td>\n",
       "      <td>1.514822e+09</td>\n",
       "      <td>1.514876e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-02 15:00:00</th>\n",
       "      <td>3878.0</td>\n",
       "      <td>3880.0</td>\n",
       "      <td>3869.0</td>\n",
       "      <td>3874.0</td>\n",
       "      <td>2413572</td>\n",
       "      <td>201602</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-02 15:00:00</td>\n",
       "      <td>3.382135e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-02</td>\n",
       "      <td>1.514822e+09</td>\n",
       "      <td>1.514876e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-03 21:15:00</th>\n",
       "      <td>3866.0</td>\n",
       "      <td>3866.0</td>\n",
       "      <td>3855.0</td>\n",
       "      <td>3863.0</td>\n",
       "      <td>2440272</td>\n",
       "      <td>253022</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-03 21:15:00</td>\n",
       "      <td>3.419549e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-03</td>\n",
       "      <td>1.514909e+09</td>\n",
       "      <td>1.514985e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-03 21:30:00</th>\n",
       "      <td>3864.0</td>\n",
       "      <td>3868.0</td>\n",
       "      <td>3857.0</td>\n",
       "      <td>3860.0</td>\n",
       "      <td>2461428</td>\n",
       "      <td>124270</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-03 21:30:00</td>\n",
       "      <td>3.449195e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-03</td>\n",
       "      <td>1.514909e+09</td>\n",
       "      <td>1.514986e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-03 21:45:00</th>\n",
       "      <td>3861.0</td>\n",
       "      <td>3873.0</td>\n",
       "      <td>3858.0</td>\n",
       "      <td>3871.0</td>\n",
       "      <td>2461948</td>\n",
       "      <td>128146</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-03 21:45:00</td>\n",
       "      <td>3.449924e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-03</td>\n",
       "      <td>1.514909e+09</td>\n",
       "      <td>1.514987e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-03 22:00:00</th>\n",
       "      <td>3871.0</td>\n",
       "      <td>3872.0</td>\n",
       "      <td>3858.0</td>\n",
       "      <td>3864.0</td>\n",
       "      <td>2472196</td>\n",
       "      <td>100256</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-03 22:00:00</td>\n",
       "      <td>3.464284e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-03</td>\n",
       "      <td>1.514909e+09</td>\n",
       "      <td>1.514988e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-03 22:15:00</th>\n",
       "      <td>3864.0</td>\n",
       "      <td>3873.0</td>\n",
       "      <td>3857.0</td>\n",
       "      <td>3867.0</td>\n",
       "      <td>2472810</td>\n",
       "      <td>122358</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-03 22:15:00</td>\n",
       "      <td>3.465145e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-03</td>\n",
       "      <td>1.514909e+09</td>\n",
       "      <td>1.514989e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-03 22:30:00</th>\n",
       "      <td>3867.0</td>\n",
       "      <td>3872.0</td>\n",
       "      <td>3865.0</td>\n",
       "      <td>3868.0</td>\n",
       "      <td>2475272</td>\n",
       "      <td>59818</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-03 22:30:00</td>\n",
       "      <td>3.468595e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-03</td>\n",
       "      <td>1.514909e+09</td>\n",
       "      <td>1.514990e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-03 22:45:00</th>\n",
       "      <td>3869.0</td>\n",
       "      <td>3871.0</td>\n",
       "      <td>3860.0</td>\n",
       "      <td>3868.0</td>\n",
       "      <td>2471526</td>\n",
       "      <td>68318</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-03 22:45:00</td>\n",
       "      <td>3.463346e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-03</td>\n",
       "      <td>1.514909e+09</td>\n",
       "      <td>1.514991e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-03 23:00:00</th>\n",
       "      <td>3868.0</td>\n",
       "      <td>3869.0</td>\n",
       "      <td>3860.0</td>\n",
       "      <td>3863.0</td>\n",
       "      <td>2449096</td>\n",
       "      <td>71270</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-03 23:00:00</td>\n",
       "      <td>3.431914e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-03</td>\n",
       "      <td>1.514909e+09</td>\n",
       "      <td>1.514992e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-03 09:15:00</th>\n",
       "      <td>3863.0</td>\n",
       "      <td>3866.0</td>\n",
       "      <td>3845.0</td>\n",
       "      <td>3854.0</td>\n",
       "      <td>2445824</td>\n",
       "      <td>250624</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-03 09:15:00</td>\n",
       "      <td>3.427329e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-03</td>\n",
       "      <td>1.514909e+09</td>\n",
       "      <td>1.514942e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-03 09:30:00</th>\n",
       "      <td>3853.0</td>\n",
       "      <td>3858.0</td>\n",
       "      <td>3851.0</td>\n",
       "      <td>3857.0</td>\n",
       "      <td>2452682</td>\n",
       "      <td>88408</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-03 09:30:00</td>\n",
       "      <td>3.436940e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-03</td>\n",
       "      <td>1.514909e+09</td>\n",
       "      <td>1.514943e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-03 09:45:00</th>\n",
       "      <td>3856.0</td>\n",
       "      <td>3859.0</td>\n",
       "      <td>3852.0</td>\n",
       "      <td>3855.0</td>\n",
       "      <td>2459606</td>\n",
       "      <td>59256</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-03 09:45:00</td>\n",
       "      <td>3.446642e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-03</td>\n",
       "      <td>1.514909e+09</td>\n",
       "      <td>1.514944e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-03 10:00:00</th>\n",
       "      <td>3855.0</td>\n",
       "      <td>3876.0</td>\n",
       "      <td>3854.0</td>\n",
       "      <td>3873.0</td>\n",
       "      <td>2454690</td>\n",
       "      <td>157042</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-03 10:00:00</td>\n",
       "      <td>3.439753e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-03</td>\n",
       "      <td>1.514909e+09</td>\n",
       "      <td>1.514945e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-03 10:15:00</th>\n",
       "      <td>3874.0</td>\n",
       "      <td>3875.0</td>\n",
       "      <td>3866.0</td>\n",
       "      <td>3866.0</td>\n",
       "      <td>2462512</td>\n",
       "      <td>89868</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-03 10:15:00</td>\n",
       "      <td>3.450714e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-03</td>\n",
       "      <td>1.514909e+09</td>\n",
       "      <td>1.514946e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-03 10:45:00</th>\n",
       "      <td>3866.0</td>\n",
       "      <td>3868.0</td>\n",
       "      <td>3852.0</td>\n",
       "      <td>3856.0</td>\n",
       "      <td>2469486</td>\n",
       "      <td>120010</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-03 10:45:00</td>\n",
       "      <td>3.460487e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-03</td>\n",
       "      <td>1.514909e+09</td>\n",
       "      <td>1.514948e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-03 11:00:00</th>\n",
       "      <td>3857.0</td>\n",
       "      <td>3859.0</td>\n",
       "      <td>3854.0</td>\n",
       "      <td>3857.0</td>\n",
       "      <td>2472910</td>\n",
       "      <td>43056</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-01-03 11:00:00</td>\n",
       "      <td>3.465285e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-01-03</td>\n",
       "      <td>1.514909e+09</td>\n",
       "      <td>1.514948e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-27 11:30:00</th>\n",
       "      <td>4002.0</td>\n",
       "      <td>4006.0</td>\n",
       "      <td>3982.0</td>\n",
       "      <td>3992.0</td>\n",
       "      <td>2499834</td>\n",
       "      <td>272200</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-27 11:30:00</td>\n",
       "      <td>3.503014e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-27</td>\n",
       "      <td>1.519661e+09</td>\n",
       "      <td>1.519702e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-27 13:45:00</th>\n",
       "      <td>3993.0</td>\n",
       "      <td>4009.0</td>\n",
       "      <td>3992.0</td>\n",
       "      <td>4007.0</td>\n",
       "      <td>2503190</td>\n",
       "      <td>134484</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-27 13:45:00</td>\n",
       "      <td>3.507716e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-27</td>\n",
       "      <td>1.519661e+09</td>\n",
       "      <td>1.519710e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-27 14:00:00</th>\n",
       "      <td>4007.0</td>\n",
       "      <td>4015.0</td>\n",
       "      <td>4004.0</td>\n",
       "      <td>4014.0</td>\n",
       "      <td>2501602</td>\n",
       "      <td>120106</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-27 14:00:00</td>\n",
       "      <td>3.505491e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-27</td>\n",
       "      <td>1.519661e+09</td>\n",
       "      <td>1.519711e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-27 14:15:00</th>\n",
       "      <td>4014.0</td>\n",
       "      <td>4026.0</td>\n",
       "      <td>4014.0</td>\n",
       "      <td>4024.0</td>\n",
       "      <td>2518878</td>\n",
       "      <td>194990</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-27 14:15:00</td>\n",
       "      <td>3.529700e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-27</td>\n",
       "      <td>1.519661e+09</td>\n",
       "      <td>1.519712e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-27 14:30:00</th>\n",
       "      <td>4024.0</td>\n",
       "      <td>4027.0</td>\n",
       "      <td>4018.0</td>\n",
       "      <td>4025.0</td>\n",
       "      <td>2515318</td>\n",
       "      <td>77490</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-27 14:30:00</td>\n",
       "      <td>3.524711e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-27</td>\n",
       "      <td>1.519661e+09</td>\n",
       "      <td>1.519713e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-27 14:45:00</th>\n",
       "      <td>4025.0</td>\n",
       "      <td>4038.0</td>\n",
       "      <td>4022.0</td>\n",
       "      <td>4037.0</td>\n",
       "      <td>2529884</td>\n",
       "      <td>206128</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-27 14:45:00</td>\n",
       "      <td>3.545123e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-27</td>\n",
       "      <td>1.519661e+09</td>\n",
       "      <td>1.519714e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-27 15:00:00</th>\n",
       "      <td>4036.0</td>\n",
       "      <td>4040.0</td>\n",
       "      <td>4029.0</td>\n",
       "      <td>4035.0</td>\n",
       "      <td>2509598</td>\n",
       "      <td>180976</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-27 15:00:00</td>\n",
       "      <td>3.516696e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-27</td>\n",
       "      <td>1.519661e+09</td>\n",
       "      <td>1.519715e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 21:15:00</th>\n",
       "      <td>4030.0</td>\n",
       "      <td>4030.0</td>\n",
       "      <td>4011.0</td>\n",
       "      <td>4014.0</td>\n",
       "      <td>2500524</td>\n",
       "      <td>200510</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 21:15:00</td>\n",
       "      <td>3.503980e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519824e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 21:30:00</th>\n",
       "      <td>4015.0</td>\n",
       "      <td>4018.0</td>\n",
       "      <td>4007.0</td>\n",
       "      <td>4016.0</td>\n",
       "      <td>2483946</td>\n",
       "      <td>126236</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 21:30:00</td>\n",
       "      <td>3.480750e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519825e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 21:45:00</th>\n",
       "      <td>4017.0</td>\n",
       "      <td>4024.0</td>\n",
       "      <td>4016.0</td>\n",
       "      <td>4021.0</td>\n",
       "      <td>2481956</td>\n",
       "      <td>63478</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 21:45:00</td>\n",
       "      <td>3.477961e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519826e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 22:00:00</th>\n",
       "      <td>4021.0</td>\n",
       "      <td>4022.0</td>\n",
       "      <td>4018.0</td>\n",
       "      <td>4018.0</td>\n",
       "      <td>2487526</td>\n",
       "      <td>29260</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 22:00:00</td>\n",
       "      <td>3.485766e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519826e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 22:15:00</th>\n",
       "      <td>4018.0</td>\n",
       "      <td>4031.0</td>\n",
       "      <td>4018.0</td>\n",
       "      <td>4031.0</td>\n",
       "      <td>2499250</td>\n",
       "      <td>90886</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 22:15:00</td>\n",
       "      <td>3.502195e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519827e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 22:30:00</th>\n",
       "      <td>4030.0</td>\n",
       "      <td>4031.0</td>\n",
       "      <td>4021.0</td>\n",
       "      <td>4028.0</td>\n",
       "      <td>2501550</td>\n",
       "      <td>73888</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 22:30:00</td>\n",
       "      <td>3.505418e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519828e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 22:45:00</th>\n",
       "      <td>4028.0</td>\n",
       "      <td>4034.0</td>\n",
       "      <td>4022.0</td>\n",
       "      <td>4031.0</td>\n",
       "      <td>2518590</td>\n",
       "      <td>74228</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 22:45:00</td>\n",
       "      <td>3.529296e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519829e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 23:00:00</th>\n",
       "      <td>4031.0</td>\n",
       "      <td>4032.0</td>\n",
       "      <td>4024.0</td>\n",
       "      <td>4025.0</td>\n",
       "      <td>2501768</td>\n",
       "      <td>58694</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 23:00:00</td>\n",
       "      <td>3.505724e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519830e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 09:15:00</th>\n",
       "      <td>4023.0</td>\n",
       "      <td>4024.0</td>\n",
       "      <td>4009.0</td>\n",
       "      <td>4014.0</td>\n",
       "      <td>2491540</td>\n",
       "      <td>173826</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 09:15:00</td>\n",
       "      <td>3.491391e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519780e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 09:30:00</th>\n",
       "      <td>4014.0</td>\n",
       "      <td>4017.0</td>\n",
       "      <td>4011.0</td>\n",
       "      <td>4012.0</td>\n",
       "      <td>2482078</td>\n",
       "      <td>60094</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 09:30:00</td>\n",
       "      <td>3.478132e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519781e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 09:45:00</th>\n",
       "      <td>4011.0</td>\n",
       "      <td>4019.0</td>\n",
       "      <td>4011.0</td>\n",
       "      <td>4015.0</td>\n",
       "      <td>2481754</td>\n",
       "      <td>35332</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 09:45:00</td>\n",
       "      <td>3.477678e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519782e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 10:00:00</th>\n",
       "      <td>4016.0</td>\n",
       "      <td>4026.0</td>\n",
       "      <td>4011.0</td>\n",
       "      <td>4024.0</td>\n",
       "      <td>2484990</td>\n",
       "      <td>92688</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 10:00:00</td>\n",
       "      <td>3.482213e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519783e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 10:15:00</th>\n",
       "      <td>4024.0</td>\n",
       "      <td>4025.0</td>\n",
       "      <td>4013.0</td>\n",
       "      <td>4015.0</td>\n",
       "      <td>2478244</td>\n",
       "      <td>59876</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 10:15:00</td>\n",
       "      <td>3.472760e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519784e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 10:45:00</th>\n",
       "      <td>4014.0</td>\n",
       "      <td>4027.0</td>\n",
       "      <td>4013.0</td>\n",
       "      <td>4025.0</td>\n",
       "      <td>2480138</td>\n",
       "      <td>59072</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 10:45:00</td>\n",
       "      <td>3.475414e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519786e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 11:00:00</th>\n",
       "      <td>4024.0</td>\n",
       "      <td>4025.0</td>\n",
       "      <td>4019.0</td>\n",
       "      <td>4023.0</td>\n",
       "      <td>2480142</td>\n",
       "      <td>25174</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 11:00:00</td>\n",
       "      <td>3.475419e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519787e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 11:15:00</th>\n",
       "      <td>4024.0</td>\n",
       "      <td>4026.0</td>\n",
       "      <td>4011.0</td>\n",
       "      <td>4013.0</td>\n",
       "      <td>2476930</td>\n",
       "      <td>65812</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 11:15:00</td>\n",
       "      <td>3.470918e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519788e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 11:30:00</th>\n",
       "      <td>4012.0</td>\n",
       "      <td>4015.0</td>\n",
       "      <td>4008.0</td>\n",
       "      <td>4011.0</td>\n",
       "      <td>2471294</td>\n",
       "      <td>97036</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 11:30:00</td>\n",
       "      <td>3.463020e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519789e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 13:45:00</th>\n",
       "      <td>4012.0</td>\n",
       "      <td>4027.0</td>\n",
       "      <td>4012.0</td>\n",
       "      <td>4022.0</td>\n",
       "      <td>2508132</td>\n",
       "      <td>174796</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 13:45:00</td>\n",
       "      <td>3.514642e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519797e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 14:00:00</th>\n",
       "      <td>4023.0</td>\n",
       "      <td>4023.0</td>\n",
       "      <td>4012.0</td>\n",
       "      <td>4018.0</td>\n",
       "      <td>2501622</td>\n",
       "      <td>89972</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 14:00:00</td>\n",
       "      <td>3.505519e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519798e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 14:15:00</th>\n",
       "      <td>4017.0</td>\n",
       "      <td>4021.0</td>\n",
       "      <td>4012.0</td>\n",
       "      <td>4013.0</td>\n",
       "      <td>2508002</td>\n",
       "      <td>63066</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 14:15:00</td>\n",
       "      <td>3.514459e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519798e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 14:30:00</th>\n",
       "      <td>4014.0</td>\n",
       "      <td>4022.0</td>\n",
       "      <td>4013.0</td>\n",
       "      <td>4021.0</td>\n",
       "      <td>2512660</td>\n",
       "      <td>42542</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 14:30:00</td>\n",
       "      <td>3.520987e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519799e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 14:45:00</th>\n",
       "      <td>4021.0</td>\n",
       "      <td>4021.0</td>\n",
       "      <td>4011.0</td>\n",
       "      <td>4014.0</td>\n",
       "      <td>2522294</td>\n",
       "      <td>66746</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 14:45:00</td>\n",
       "      <td>3.534487e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519800e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-28 15:00:00</th>\n",
       "      <td>4014.0</td>\n",
       "      <td>4025.0</td>\n",
       "      <td>4013.0</td>\n",
       "      <td>4020.0</td>\n",
       "      <td>2523848</td>\n",
       "      <td>181496</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2018-02-28 15:00:00</td>\n",
       "      <td>3.536664e-39</td>\n",
       "      <td>RBL8</td>\n",
       "      <td>2018-02-28</td>\n",
       "      <td>1.519747e+09</td>\n",
       "      <td>1.519801e+09</td>\n",
       "      <td>15min</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>835 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                       open    high     low   close  position   trade  price  \\\n",
       "datetime                                                                       \n",
       "2018-01-02 09:15:00  3801.0  3809.0  3794.0  3798.0   2520510  312684    0.0   \n",
       "2018-01-02 09:30:00  3799.0  3834.0  3797.0  3830.0   2501350  418536    0.0   \n",
       "2018-01-02 09:45:00  3829.0  3831.0  3819.0  3822.0   2498648  137928    0.0   \n",
       "2018-01-02 10:00:00  3823.0  3824.0  3812.0  3822.0   2501706  116806    0.0   \n",
       "2018-01-02 10:15:00  3822.0  3825.0  3818.0  3824.0   2510106   68888    0.0   \n",
       "2018-01-02 10:45:00  3824.0  3828.0  3821.0  3823.0   2513434   71846    0.0   \n",
       "2018-01-02 11:00:00  3824.0  3833.0  3820.0  3824.0   2526064  156954    0.0   \n",
       "2018-01-02 11:15:00  3824.0  3830.0  3821.0  3826.0   2521712   77962    0.0   \n",
       "2018-01-02 11:30:00  3825.0  3872.0  3819.0  3871.0   2464210  538316    0.0   \n",
       "2018-01-02 13:45:00  3872.0  3879.0  3867.0  3871.0   2437082  339672    0.0   \n",
       "2018-01-02 14:00:00  3873.0  3874.0  3862.0  3866.0   2441464  122992    0.0   \n",
       "2018-01-02 14:15:00  3866.0  3875.0  3864.0  3875.0   2448522   93220    0.0   \n",
       "2018-01-02 14:30:00  3874.0  3877.0  3867.0  3873.0   2455406   89550    0.0   \n",
       "2018-01-02 14:45:00  3873.0  3886.0  3872.0  3879.0   2449654  209192    0.0   \n",
       "2018-01-02 15:00:00  3878.0  3880.0  3869.0  3874.0   2413572  201602    0.0   \n",
       "2018-01-03 21:15:00  3866.0  3866.0  3855.0  3863.0   2440272  253022    0.0   \n",
       "2018-01-03 21:30:00  3864.0  3868.0  3857.0  3860.0   2461428  124270    0.0   \n",
       "2018-01-03 21:45:00  3861.0  3873.0  3858.0  3871.0   2461948  128146    0.0   \n",
       "2018-01-03 22:00:00  3871.0  3872.0  3858.0  3864.0   2472196  100256    0.0   \n",
       "2018-01-03 22:15:00  3864.0  3873.0  3857.0  3867.0   2472810  122358    0.0   \n",
       "2018-01-03 22:30:00  3867.0  3872.0  3865.0  3868.0   2475272   59818    0.0   \n",
       "2018-01-03 22:45:00  3869.0  3871.0  3860.0  3868.0   2471526   68318    0.0   \n",
       "2018-01-03 23:00:00  3868.0  3869.0  3860.0  3863.0   2449096   71270    0.0   \n",
       "2018-01-03 09:15:00  3863.0  3866.0  3845.0  3854.0   2445824  250624    0.0   \n",
       "2018-01-03 09:30:00  3853.0  3858.0  3851.0  3857.0   2452682   88408    0.0   \n",
       "2018-01-03 09:45:00  3856.0  3859.0  3852.0  3855.0   2459606   59256    0.0   \n",
       "2018-01-03 10:00:00  3855.0  3876.0  3854.0  3873.0   2454690  157042    0.0   \n",
       "2018-01-03 10:15:00  3874.0  3875.0  3866.0  3866.0   2462512   89868    0.0   \n",
       "2018-01-03 10:45:00  3866.0  3868.0  3852.0  3856.0   2469486  120010    0.0   \n",
       "2018-01-03 11:00:00  3857.0  3859.0  3854.0  3857.0   2472910   43056    0.0   \n",
       "...                     ...     ...     ...     ...       ...     ...    ...   \n",
       "2018-02-27 11:30:00  4002.0  4006.0  3982.0  3992.0   2499834  272200    0.0   \n",
       "2018-02-27 13:45:00  3993.0  4009.0  3992.0  4007.0   2503190  134484    0.0   \n",
       "2018-02-27 14:00:00  4007.0  4015.0  4004.0  4014.0   2501602  120106    0.0   \n",
       "2018-02-27 14:15:00  4014.0  4026.0  4014.0  4024.0   2518878  194990    0.0   \n",
       "2018-02-27 14:30:00  4024.0  4027.0  4018.0  4025.0   2515318   77490    0.0   \n",
       "2018-02-27 14:45:00  4025.0  4038.0  4022.0  4037.0   2529884  206128    0.0   \n",
       "2018-02-27 15:00:00  4036.0  4040.0  4029.0  4035.0   2509598  180976    0.0   \n",
       "2018-02-28 21:15:00  4030.0  4030.0  4011.0  4014.0   2500524  200510    0.0   \n",
       "2018-02-28 21:30:00  4015.0  4018.0  4007.0  4016.0   2483946  126236    0.0   \n",
       "2018-02-28 21:45:00  4017.0  4024.0  4016.0  4021.0   2481956   63478    0.0   \n",
       "2018-02-28 22:00:00  4021.0  4022.0  4018.0  4018.0   2487526   29260    0.0   \n",
       "2018-02-28 22:15:00  4018.0  4031.0  4018.0  4031.0   2499250   90886    0.0   \n",
       "2018-02-28 22:30:00  4030.0  4031.0  4021.0  4028.0   2501550   73888    0.0   \n",
       "2018-02-28 22:45:00  4028.0  4034.0  4022.0  4031.0   2518590   74228    0.0   \n",
       "2018-02-28 23:00:00  4031.0  4032.0  4024.0  4025.0   2501768   58694    0.0   \n",
       "2018-02-28 09:15:00  4023.0  4024.0  4009.0  4014.0   2491540  173826    0.0   \n",
       "2018-02-28 09:30:00  4014.0  4017.0  4011.0  4012.0   2482078   60094    0.0   \n",
       "2018-02-28 09:45:00  4011.0  4019.0  4011.0  4015.0   2481754   35332    0.0   \n",
       "2018-02-28 10:00:00  4016.0  4026.0  4011.0  4024.0   2484990   92688    0.0   \n",
       "2018-02-28 10:15:00  4024.0  4025.0  4013.0  4015.0   2478244   59876    0.0   \n",
       "2018-02-28 10:45:00  4014.0  4027.0  4013.0  4025.0   2480138   59072    0.0   \n",
       "2018-02-28 11:00:00  4024.0  4025.0  4019.0  4023.0   2480142   25174    0.0   \n",
       "2018-02-28 11:15:00  4024.0  4026.0  4011.0  4013.0   2476930   65812    0.0   \n",
       "2018-02-28 11:30:00  4012.0  4015.0  4008.0  4011.0   2471294   97036    0.0   \n",
       "2018-02-28 13:45:00  4012.0  4027.0  4012.0  4022.0   2508132  174796    0.0   \n",
       "2018-02-28 14:00:00  4023.0  4023.0  4012.0  4018.0   2501622   89972    0.0   \n",
       "2018-02-28 14:15:00  4017.0  4021.0  4012.0  4013.0   2508002   63066    0.0   \n",
       "2018-02-28 14:30:00  4014.0  4022.0  4013.0  4021.0   2512660   42542    0.0   \n",
       "2018-02-28 14:45:00  4021.0  4021.0  4011.0  4014.0   2522294   66746    0.0   \n",
       "2018-02-28 15:00:00  4014.0  4025.0  4013.0  4020.0   2523848  181496    0.0   \n",
       "\n",
       "                                datetime        amount  code        date  \\\n",
       "datetime                                                                   \n",
       "2018-01-02 09:15:00  2018-01-02 09:15:00  3.531987e-39  RBL8  2018-01-02   \n",
       "2018-01-02 09:30:00  2018-01-02 09:30:00  3.505138e-39  RBL8  2018-01-02   \n",
       "2018-01-02 09:45:00  2018-01-02 09:45:00  3.501352e-39  RBL8  2018-01-02   \n",
       "2018-01-02 10:00:00  2018-01-02 10:00:00  3.505637e-39  RBL8  2018-01-02   \n",
       "2018-01-02 10:15:00  2018-01-02 10:15:00  3.517408e-39  RBL8  2018-01-02   \n",
       "2018-01-02 10:45:00  2018-01-02 10:45:00  3.522071e-39  RBL8  2018-01-02   \n",
       "2018-01-02 11:00:00  2018-01-02 11:00:00  3.539770e-39  RBL8  2018-01-02   \n",
       "2018-01-02 11:15:00  2018-01-02 11:15:00  3.533671e-39  RBL8  2018-01-02   \n",
       "2018-01-02 11:30:00  2018-01-02 11:30:00  3.453094e-39  RBL8  2018-01-02   \n",
       "2018-01-02 13:45:00  2018-01-02 13:45:00  3.415079e-39  RBL8  2018-01-02   \n",
       "2018-01-02 14:00:00  2018-01-02 14:00:00  3.421220e-39  RBL8  2018-01-02   \n",
       "2018-01-02 14:15:00  2018-01-02 14:15:00  3.431110e-39  RBL8  2018-01-02   \n",
       "2018-01-02 14:30:00  2018-01-02 14:30:00  3.440757e-39  RBL8  2018-01-02   \n",
       "2018-01-02 14:45:00  2018-01-02 14:45:00  3.432696e-39  RBL8  2018-01-02   \n",
       "2018-01-02 15:00:00  2018-01-02 15:00:00  3.382135e-39  RBL8  2018-01-02   \n",
       "2018-01-03 21:15:00  2018-01-03 21:15:00  3.419549e-39  RBL8  2018-01-03   \n",
       "2018-01-03 21:30:00  2018-01-03 21:30:00  3.449195e-39  RBL8  2018-01-03   \n",
       "2018-01-03 21:45:00  2018-01-03 21:45:00  3.449924e-39  RBL8  2018-01-03   \n",
       "2018-01-03 22:00:00  2018-01-03 22:00:00  3.464284e-39  RBL8  2018-01-03   \n",
       "2018-01-03 22:15:00  2018-01-03 22:15:00  3.465145e-39  RBL8  2018-01-03   \n",
       "2018-01-03 22:30:00  2018-01-03 22:30:00  3.468595e-39  RBL8  2018-01-03   \n",
       "2018-01-03 22:45:00  2018-01-03 22:45:00  3.463346e-39  RBL8  2018-01-03   \n",
       "2018-01-03 23:00:00  2018-01-03 23:00:00  3.431914e-39  RBL8  2018-01-03   \n",
       "2018-01-03 09:15:00  2018-01-03 09:15:00  3.427329e-39  RBL8  2018-01-03   \n",
       "2018-01-03 09:30:00  2018-01-03 09:30:00  3.436940e-39  RBL8  2018-01-03   \n",
       "2018-01-03 09:45:00  2018-01-03 09:45:00  3.446642e-39  RBL8  2018-01-03   \n",
       "2018-01-03 10:00:00  2018-01-03 10:00:00  3.439753e-39  RBL8  2018-01-03   \n",
       "2018-01-03 10:15:00  2018-01-03 10:15:00  3.450714e-39  RBL8  2018-01-03   \n",
       "2018-01-03 10:45:00  2018-01-03 10:45:00  3.460487e-39  RBL8  2018-01-03   \n",
       "2018-01-03 11:00:00  2018-01-03 11:00:00  3.465285e-39  RBL8  2018-01-03   \n",
       "...                                  ...           ...   ...         ...   \n",
       "2018-02-27 11:30:00  2018-02-27 11:30:00  3.503014e-39  RBL8  2018-02-27   \n",
       "2018-02-27 13:45:00  2018-02-27 13:45:00  3.507716e-39  RBL8  2018-02-27   \n",
       "2018-02-27 14:00:00  2018-02-27 14:00:00  3.505491e-39  RBL8  2018-02-27   \n",
       "2018-02-27 14:15:00  2018-02-27 14:15:00  3.529700e-39  RBL8  2018-02-27   \n",
       "2018-02-27 14:30:00  2018-02-27 14:30:00  3.524711e-39  RBL8  2018-02-27   \n",
       "2018-02-27 14:45:00  2018-02-27 14:45:00  3.545123e-39  RBL8  2018-02-27   \n",
       "2018-02-27 15:00:00  2018-02-27 15:00:00  3.516696e-39  RBL8  2018-02-27   \n",
       "2018-02-28 21:15:00  2018-02-28 21:15:00  3.503980e-39  RBL8  2018-02-28   \n",
       "2018-02-28 21:30:00  2018-02-28 21:30:00  3.480750e-39  RBL8  2018-02-28   \n",
       "2018-02-28 21:45:00  2018-02-28 21:45:00  3.477961e-39  RBL8  2018-02-28   \n",
       "2018-02-28 22:00:00  2018-02-28 22:00:00  3.485766e-39  RBL8  2018-02-28   \n",
       "2018-02-28 22:15:00  2018-02-28 22:15:00  3.502195e-39  RBL8  2018-02-28   \n",
       "2018-02-28 22:30:00  2018-02-28 22:30:00  3.505418e-39  RBL8  2018-02-28   \n",
       "2018-02-28 22:45:00  2018-02-28 22:45:00  3.529296e-39  RBL8  2018-02-28   \n",
       "2018-02-28 23:00:00  2018-02-28 23:00:00  3.505724e-39  RBL8  2018-02-28   \n",
       "2018-02-28 09:15:00  2018-02-28 09:15:00  3.491391e-39  RBL8  2018-02-28   \n",
       "2018-02-28 09:30:00  2018-02-28 09:30:00  3.478132e-39  RBL8  2018-02-28   \n",
       "2018-02-28 09:45:00  2018-02-28 09:45:00  3.477678e-39  RBL8  2018-02-28   \n",
       "2018-02-28 10:00:00  2018-02-28 10:00:00  3.482213e-39  RBL8  2018-02-28   \n",
       "2018-02-28 10:15:00  2018-02-28 10:15:00  3.472760e-39  RBL8  2018-02-28   \n",
       "2018-02-28 10:45:00  2018-02-28 10:45:00  3.475414e-39  RBL8  2018-02-28   \n",
       "2018-02-28 11:00:00  2018-02-28 11:00:00  3.475419e-39  RBL8  2018-02-28   \n",
       "2018-02-28 11:15:00  2018-02-28 11:15:00  3.470918e-39  RBL8  2018-02-28   \n",
       "2018-02-28 11:30:00  2018-02-28 11:30:00  3.463020e-39  RBL8  2018-02-28   \n",
       "2018-02-28 13:45:00  2018-02-28 13:45:00  3.514642e-39  RBL8  2018-02-28   \n",
       "2018-02-28 14:00:00  2018-02-28 14:00:00  3.505519e-39  RBL8  2018-02-28   \n",
       "2018-02-28 14:15:00  2018-02-28 14:15:00  3.514459e-39  RBL8  2018-02-28   \n",
       "2018-02-28 14:30:00  2018-02-28 14:30:00  3.520987e-39  RBL8  2018-02-28   \n",
       "2018-02-28 14:45:00  2018-02-28 14:45:00  3.534487e-39  RBL8  2018-02-28   \n",
       "2018-02-28 15:00:00  2018-02-28 15:00:00  3.536664e-39  RBL8  2018-02-28   \n",
       "\n",
       "                       date_stamp    time_stamp   type  \n",
       "datetime                                                \n",
       "2018-01-02 09:15:00  1.514822e+09  1.514856e+09  15min  \n",
       "2018-01-02 09:30:00  1.514822e+09  1.514857e+09  15min  \n",
       "2018-01-02 09:45:00  1.514822e+09  1.514858e+09  15min  \n",
       "2018-01-02 10:00:00  1.514822e+09  1.514858e+09  15min  \n",
       "2018-01-02 10:15:00  1.514822e+09  1.514859e+09  15min  \n",
       "2018-01-02 10:45:00  1.514822e+09  1.514861e+09  15min  \n",
       "2018-01-02 11:00:00  1.514822e+09  1.514862e+09  15min  \n",
       "2018-01-02 11:15:00  1.514822e+09  1.514863e+09  15min  \n",
       "2018-01-02 11:30:00  1.514822e+09  1.514864e+09  15min  \n",
       "2018-01-02 13:45:00  1.514822e+09  1.514872e+09  15min  \n",
       "2018-01-02 14:00:00  1.514822e+09  1.514873e+09  15min  \n",
       "2018-01-02 14:15:00  1.514822e+09  1.514874e+09  15min  \n",
       "2018-01-02 14:30:00  1.514822e+09  1.514875e+09  15min  \n",
       "2018-01-02 14:45:00  1.514822e+09  1.514876e+09  15min  \n",
       "2018-01-02 15:00:00  1.514822e+09  1.514876e+09  15min  \n",
       "2018-01-03 21:15:00  1.514909e+09  1.514985e+09  15min  \n",
       "2018-01-03 21:30:00  1.514909e+09  1.514986e+09  15min  \n",
       "2018-01-03 21:45:00  1.514909e+09  1.514987e+09  15min  \n",
       "2018-01-03 22:00:00  1.514909e+09  1.514988e+09  15min  \n",
       "2018-01-03 22:15:00  1.514909e+09  1.514989e+09  15min  \n",
       "2018-01-03 22:30:00  1.514909e+09  1.514990e+09  15min  \n",
       "2018-01-03 22:45:00  1.514909e+09  1.514991e+09  15min  \n",
       "2018-01-03 23:00:00  1.514909e+09  1.514992e+09  15min  \n",
       "2018-01-03 09:15:00  1.514909e+09  1.514942e+09  15min  \n",
       "2018-01-03 09:30:00  1.514909e+09  1.514943e+09  15min  \n",
       "2018-01-03 09:45:00  1.514909e+09  1.514944e+09  15min  \n",
       "2018-01-03 10:00:00  1.514909e+09  1.514945e+09  15min  \n",
       "2018-01-03 10:15:00  1.514909e+09  1.514946e+09  15min  \n",
       "2018-01-03 10:45:00  1.514909e+09  1.514948e+09  15min  \n",
       "2018-01-03 11:00:00  1.514909e+09  1.514948e+09  15min  \n",
       "...                           ...           ...    ...  \n",
       "2018-02-27 11:30:00  1.519661e+09  1.519702e+09  15min  \n",
       "2018-02-27 13:45:00  1.519661e+09  1.519710e+09  15min  \n",
       "2018-02-27 14:00:00  1.519661e+09  1.519711e+09  15min  \n",
       "2018-02-27 14:15:00  1.519661e+09  1.519712e+09  15min  \n",
       "2018-02-27 14:30:00  1.519661e+09  1.519713e+09  15min  \n",
       "2018-02-27 14:45:00  1.519661e+09  1.519714e+09  15min  \n",
       "2018-02-27 15:00:00  1.519661e+09  1.519715e+09  15min  \n",
       "2018-02-28 21:15:00  1.519747e+09  1.519824e+09  15min  \n",
       "2018-02-28 21:30:00  1.519747e+09  1.519825e+09  15min  \n",
       "2018-02-28 21:45:00  1.519747e+09  1.519826e+09  15min  \n",
       "2018-02-28 22:00:00  1.519747e+09  1.519826e+09  15min  \n",
       "2018-02-28 22:15:00  1.519747e+09  1.519827e+09  15min  \n",
       "2018-02-28 22:30:00  1.519747e+09  1.519828e+09  15min  \n",
       "2018-02-28 22:45:00  1.519747e+09  1.519829e+09  15min  \n",
       "2018-02-28 23:00:00  1.519747e+09  1.519830e+09  15min  \n",
       "2018-02-28 09:15:00  1.519747e+09  1.519780e+09  15min  \n",
       "2018-02-28 09:30:00  1.519747e+09  1.519781e+09  15min  \n",
       "2018-02-28 09:45:00  1.519747e+09  1.519782e+09  15min  \n",
       "2018-02-28 10:00:00  1.519747e+09  1.519783e+09  15min  \n",
       "2018-02-28 10:15:00  1.519747e+09  1.519784e+09  15min  \n",
       "2018-02-28 10:45:00  1.519747e+09  1.519786e+09  15min  \n",
       "2018-02-28 11:00:00  1.519747e+09  1.519787e+09  15min  \n",
       "2018-02-28 11:15:00  1.519747e+09  1.519788e+09  15min  \n",
       "2018-02-28 11:30:00  1.519747e+09  1.519789e+09  15min  \n",
       "2018-02-28 13:45:00  1.519747e+09  1.519797e+09  15min  \n",
       "2018-02-28 14:00:00  1.519747e+09  1.519798e+09  15min  \n",
       "2018-02-28 14:15:00  1.519747e+09  1.519798e+09  15min  \n",
       "2018-02-28 14:30:00  1.519747e+09  1.519799e+09  15min  \n",
       "2018-02-28 14:45:00  1.519747e+09  1.519800e+09  15min  \n",
       "2018-02-28 15:00:00  1.519747e+09  1.519801e+09  15min  \n",
       "\n",
       "[835 rows x 14 columns]"
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 全仓买入'000001'\n",
    "hq=next(rb_ds.panel_gen)\n",
    "order=AccountFuture.send_order(code='RBL8',\n",
    "                        price=hq.open,\n",
    "                        money=AccountFuture.cash_available,\n",
    "                        time=hq.datetime[0],\n",
    "                        towards=QA.ORDER_DIRECTION.BUY,\n",
    "                        order_model=QA.ORDER_MODEL.MARKET,\n",
    "                        amount_model=QA.AMOUNT_MODEL.BY_MONEY\n",
    "                        )\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "< QA_Order realorder_id Order_1YzjQXi6 datetime:2018-01-02 09:15:00 code:RBL8 amount:200 price:3801.5 towards:1 btype:future_cn order_id:Order_1YzjQXi6 account:future_test status:queued >"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Broker.receive_order(QA.QA_Event(order=order,market_data=hq))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "receive deal\n"
     ]
    }
   ],
   "source": [
    "trade_mes = Broker.query_orders(AccountFuture.account_cookie, 'filled')\n",
    "res = trade_mes.loc[order.account_cookie, order.realorder_id]\n",
    "order.trade(res.trade_id, res.trade_price, res.trade_amount, res.trade_time)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
